home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / pc_board / ansi_d.zip / ANSI-D.PPS < prev    next >
Text File  |  1993-04-07  |  5KB  |  106 lines

  1. ;*****************************************************************************
  2. ;*                                                                           *
  3. ;*                           ANSI DETECTION V1.1                             *
  4. ;*                                                                           *
  5. ;*                        written by: Steve Catmull                          *
  6. ;*                                                                           *
  7. ;*                            started: 03-26-93                              *
  8. ;*                                                                           *
  9. ;*****************************************************************************
  10.  
  11.  
  12. BOOLEAN hasansi    ; Result of ANSI - detection test (true or false)
  13. STRING  graphdef   ; Stores response to the "ask" prompt below
  14. STRING  ask        ; Constant that contains "want graphics" minus default resp.
  15. INTEGER wtime      ; Used as a constant to define seconds to wait - ANSI detect
  16. STRING  temp       ; Stores the token of what user inputed. 
  17. BOOLEAN switch     ; Used to help fool around with the defaults.
  18. STRING default_yes ; Used to store setting from PCBOARD.DAT for the default
  19.  
  20. wtime  = 2                              ; Seconds to wait for ANSI response
  21. temp   = " "                            ; Initialized to non null for WHILE
  22. switch = FALSE
  23.  
  24. ; /* Notifying the user that ANSI detection is being processed.  This keeps
  25. ;    them entertainment while the "wtime" pause is being executed.  */
  26.  
  27. PRINTLN "Testing your system capability..."   ; Amusing the caller.
  28.  
  29. ; /* If you user is connected locally then default autoamtically to ANSI
  30. ;    capable.  Otherwise, send out the escape sequence to get the current
  31. ;    cursor position.  Immediately follow that with a bunch of backspace
  32. ;    space backspace sequences in case they do not have the ability to
  33. ;    interpret ANSI.  Otherwise, it may be left on the screen.  Finally,
  34. ;    wait for the and ESC followed by a left bracket to be returned.  This
  35. ;    is the only constant part of the ANSI detection that can be tested.
  36. ;    If that sequence is returned within WTIME seconds, then the caller 
  37. ;    is considered to be ANSI capable and the HASANSI variable shows it.
  38. ;
  39. ;    NOTE:  Evidently some terminal programs are quite lazy in returning
  40. ;           the response to the ANSI detection test.  This PPE does not 
  41. ;           attempt to make any accomodations for those programs.  Instead,
  42. ;           it waits "WTIME" seconds and then continues with the best that
  43. ;           has been determined by that time.                            */
  44.  
  45. IF (!ONLOCAL()) THEN
  46.    PRINT CHR(27)+"[6n"
  47.    PRINT "     "
  48.    WAITFOR chr(27)+"[",hasansi,wtime
  49. ELSE
  50.    hasansi=-1
  51. ENDIF
  52.  
  53. ; /* Assign ASK variable to prompt used for ANSI.  The default if enter is
  54. ;    pressed is ommitted so that it may be built according to their ANSI
  55. ;    capabilities.                                                       */
  56.  
  57. ask = "Do you want graphics (Enter)="  
  58.  
  59. ; /* Read line #257 in PCBOARD.DAT to find out what the default for the 
  60. ;    "Do you want graphics" prompt is.  Store the result in DEFAULT_YES.
  61.  
  62. default_yes = READLINE(PCBDAT(),257)
  63.  
  64. ; /* If the user is capable of ANSI, then default for the "want graphics"
  65. ;    prompt will be Yes, otherwise, the default is set to "N".  The point
  66. ;    in asking the question is to enable the user to still choose if they
  67. ;    wish to see color or not, but if they do not know how to answer the
  68. ;    question, then the default will give them color if they are capable
  69. ;    of handling it.
  70.  
  71. IF (hasansi) THEN
  72.    ask=ask+"yes"
  73.    INPUTSTR ask,graphdef,07,6," ;YQNS",110011010b
  74.    IF (!default_yes) THEN
  75.       TOKENIZE graphdef                              ; Necessary because if user
  76.       WHILE (!temp="") DO                            ; enters something like Q
  77.          GETTOKEN temp                               ; at "want graphics" prompt
  78.          IF (temp=NOCHAR()) switch=TRUE              ; the default should remain.
  79.       ENDWHILE                                       ; Since we are fooling PCB
  80.       IF (!switch) graphdef=YESCHAR()+";"+graphdef   ; we need to handle it.      
  81.    ENDIF
  82. ELSE
  83.    ask=ask+"no"
  84.    INPUTSTR ask,graphdef,07,6," ;YQNS",110011010b
  85.    IF (default_yes) THEN
  86.       TOKENIZE graphdef
  87.       WHILE (!temp="") DO
  88.          GETTOKEN temp
  89.          IF (temp=YESCHAR()) switch=TRUE
  90.       ENDWHILE
  91.       IF (!switch) graphdef=NOCHAR()+";"+graphdef
  92.    ENDIF
  93. ENDIF
  94.  
  95. ;PRINTLN
  96.  
  97. ; /* Now that the "want graphics" prompt has been faked so that the default
  98. ;    value could be controlled, it is time to stuff the users response to 
  99. ;    the fake prompt to the real prompt.  This inludes the "Q and NS" 
  100. ;    parameters.                                                           */
  101.  
  102. KBDSTUFF graphdef 
  103.  
  104. END                                    ; end of script
  105.  
  106.